package com.topboya.officeuser.wx;

import com.topboya.officeuser.service.WxPayService;
import com.topboya.officeuser.utils.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @className WxPayController
 * @Author xiaxin
 * @Date 2020/12/21 11:12
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/trade/weixin-pay")
@Api(description = "网站微信支付")
@CrossOrigin //跨域
@Slf4j
public class WxPayController {

    @Autowired
    private WxPayService wxPayService;

    @GetMapping("create-native/{orderNo}")
    public Result createNative(@PathVariable String orderNo, HttpServletRequest request) throws Exception {
        String remoteAddr = request.getRemoteAddr();
        Map map = wxPayService.createNative(orderNo,remoteAddr);
        return Result.ok().data(map);
    }

    @GetMapping("callback/notify")
    public Result callBack(@PathVariable String orderNo, HttpServletRequest request) throws Exception {
        System.out.println("方法回调了");
        return Result.ok();
    }




}
